package p270jp.pxv.android.viewholder;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import androidx.databinding.DataBindingUtil;
import java.util.Objects;
import p013ad.Consumer;
import p014ae.C0147r4;
import p014ae.View$OnClickListenerC0050b;
import p014ae.View$OnClickListenerC0163u;
import p047bg.C1124a;
import p165fo.C3114c;
import p187gl.C3365n;
import p210hh.PixivAccountManager;
import p216hn.DefaultConstructorMarker;
import p258jd.SingleDoAfterTerminate;
import p258jd.SingleDoOnSubscribe;
import p258jd.SingleFlatMap;
import p270jp.pxv.android.R;
import p270jp.pxv.android.event.ReloadHomeEvent;
import p270jp.pxv.android.model.PixivPrivacyPolicy;
import p270jp.pxv.android.response.PixivResponse;
import p314lg.ViewHomeGdprBinding;
import p325m0.MutabilityOwnership;
import p350mp.Timber;
import p468re.AccessTokenLifetimeService;
import p521th.SolidItemViewHolder;
import p547uh.C6513q0;
import p569vd.C6830b;
import p593wc.Single;
import p645yc.AndroidSchedulers;
import p671zc.CompositeDisposable;
import p671zc.Disposable;

/* compiled from: GdprSolidItemViewHolder.kt */
@SuppressLint({"RxJava2MissingCompositeDisposableClear"})
/* renamed from: jp.pxv.android.viewholder.GdprSolidItemViewHolder */
/* loaded from: classes2.dex */
public final class GdprSolidItemViewHolder extends SolidItemViewHolder {
    private final AccessTokenLifetimeService accessTokenLifetimeService;
    private final ViewHomeGdprBinding binding;
    private final CompositeDisposable compositeDisposable;
    private final PixivPrivacyPolicy privacyPolicy;
    private boolean requesting;
    public static final Companion Companion = new Companion(null);
    public static final int $stable = 8;
    private static final String TAG = "GdprSolidItemViewHolder";

    /* compiled from: GdprSolidItemViewHolder.kt */
    /* renamed from: jp.pxv.android.viewholder.GdprSolidItemViewHolder$Companion */
    /* loaded from: classes2.dex */
    public static final class Companion {
        private Companion() {
        }

        public /* synthetic */ Companion(DefaultConstructorMarker eVar) {
            this();
        }

        public final GdprSolidItemViewHolder createViewHolder(ViewGroup viewGroup, PixivPrivacyPolicy pixivPrivacyPolicy, AccessTokenLifetimeService aVar, CompositeDisposable aVar2) {
            MutabilityOwnership.m3745m(viewGroup, "parent");
            MutabilityOwnership.m3745m(pixivPrivacyPolicy, "privacyPolicy");
            MutabilityOwnership.m3745m(aVar, "accessTokenLifetimeService");
            MutabilityOwnership.m3745m(aVar2, "compositeDisposable");
            ViewHomeGdprBinding e9Var = (ViewHomeGdprBinding) DataBindingUtil.m11370c(LayoutInflater.from(viewGroup.getContext()), R.layout.view_home_gdpr, viewGroup, false);
            MutabilityOwnership.m3746l(e9Var, "binding");
            return new GdprSolidItemViewHolder(e9Var, pixivPrivacyPolicy, aVar, aVar2, null);
        }
    }

    private GdprSolidItemViewHolder(ViewHomeGdprBinding e9Var, PixivPrivacyPolicy pixivPrivacyPolicy, AccessTokenLifetimeService aVar, CompositeDisposable aVar2) {
        super(e9Var.f2666e);
        this.binding = e9Var;
        this.privacyPolicy = pixivPrivacyPolicy;
        this.accessTokenLifetimeService = aVar;
        this.compositeDisposable = aVar2;
    }

    public /* synthetic */ GdprSolidItemViewHolder(ViewHomeGdprBinding e9Var, PixivPrivacyPolicy pixivPrivacyPolicy, AccessTokenLifetimeService aVar, CompositeDisposable aVar2, DefaultConstructorMarker eVar) {
        this(e9Var, pixivPrivacyPolicy, aVar, aVar2);
    }

    /* renamed from: a */
    public static /* synthetic */ void m4444a(GdprSolidItemViewHolder gdprSolidItemViewHolder, PixivResponse pixivResponse) {
        m12311onBindViewHolder$lambda5$lambda3(gdprSolidItemViewHolder, pixivResponse);
    }

    /* renamed from: j */
    public static /* synthetic */ void m4439j(GdprSolidItemViewHolder gdprSolidItemViewHolder, View view) {
        m12307onBindViewHolder$lambda0(gdprSolidItemViewHolder, view);
    }

    /* renamed from: onBindViewHolder$lambda-0 */
    public static final void m12307onBindViewHolder$lambda0(GdprSolidItemViewHolder gdprSolidItemViewHolder, View view) {
        MutabilityOwnership.m3745m(gdprSolidItemViewHolder, "this$0");
        Context context = gdprSolidItemViewHolder.itemView.getContext();
        MutabilityOwnership.m3746l(context, "itemView.context");
        C1124a.m10213A(context, gdprSolidItemViewHolder.privacyPolicy.getUrl());
    }

    /* renamed from: onBindViewHolder$lambda-5 */
    public static final void m12308onBindViewHolder$lambda5(GdprSolidItemViewHolder gdprSolidItemViewHolder, View view) {
        MutabilityOwnership.m3745m(gdprSolidItemViewHolder, "this$0");
        if (!gdprSolidItemViewHolder.requesting) {
            CompositeDisposable aVar = gdprSolidItemViewHolder.compositeDisposable;
            String version = gdprSolidItemViewHolder.privacyPolicy.getVersion();
            Single<String> c = PixivAccountManager.m5511e().m5513c();
            C3365n nVar = new C3365n(version, 1);
            Objects.requireNonNull(c);
            aVar.mo82c(new SingleDoAfterTerminate(new SingleDoOnSubscribe(new SingleFlatMap(c, nVar).m966j(AndroidSchedulers.m334a()), new Consumer() { // from class: jp.pxv.android.viewholder.c
                @Override // p013ad.Consumer
                /* renamed from: d */
                public final void mo1150d(Object obj) {
                    GdprSolidItemViewHolder.m12309onBindViewHolder$lambda5$lambda1(GdprSolidItemViewHolder.this, (Disposable) obj);
                }
            }), new C6513q0(gdprSolidItemViewHolder, 2)).m963m(new C6830b(gdprSolidItemViewHolder, 21), new C0147r4(gdprSolidItemViewHolder, 22)));
        }
    }

    /* renamed from: onBindViewHolder$lambda-5$lambda-1 */
    public static final void m12309onBindViewHolder$lambda5$lambda1(GdprSolidItemViewHolder gdprSolidItemViewHolder, Disposable bVar) {
        MutabilityOwnership.m3745m(gdprSolidItemViewHolder, "this$0");
        gdprSolidItemViewHolder.requesting = true;
    }

    /* renamed from: onBindViewHolder$lambda-5$lambda-2 */
    public static final void m12310onBindViewHolder$lambda5$lambda2(GdprSolidItemViewHolder gdprSolidItemViewHolder) {
        MutabilityOwnership.m3745m(gdprSolidItemViewHolder, "this$0");
        gdprSolidItemViewHolder.requesting = false;
    }

    /* renamed from: onBindViewHolder$lambda-5$lambda-3 */
    public static final void m12311onBindViewHolder$lambda5$lambda3(GdprSolidItemViewHolder gdprSolidItemViewHolder, PixivResponse pixivResponse) {
        MutabilityOwnership.m3745m(gdprSolidItemViewHolder, "this$0");
        gdprSolidItemViewHolder.accessTokenLifetimeService.m2587a();
        C3114c.m6284b().m6280f(new ReloadHomeEvent());
    }

    /* renamed from: onBindViewHolder$lambda-5$lambda-4 */
    public static final void m12312onBindViewHolder$lambda5$lambda4(GdprSolidItemViewHolder gdprSolidItemViewHolder, Throwable th) {
        MutabilityOwnership.m3745m(gdprSolidItemViewHolder, "this$0");
        Toast.makeText(gdprSolidItemViewHolder.itemView.getContext(), (int) R.string.error_default_message, 1).show();
        Timber.f23100a.mo3514p(th);
    }

    @Override // p521th.SolidItemViewHolder
    public void onBindViewHolder(int i) {
        this.binding.f21520s.setOnClickListener(new View$OnClickListenerC0163u(this, 25));
        this.binding.f21519r.setText(this.privacyPolicy.getMessage());
        this.binding.f21518q.setOnClickListener(new View$OnClickListenerC0050b(this, 23));
    }
}
